package v1

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"new_ginblog/internal/repositories"
	"new_ginblog/internal/utils/errormsg"
)

func UpLoadFile(c *gin.Context) {
	file, fileHeader, _ := c.Request.FormFile("file")
	fileSize := fileHeader.Size

	url, code := repositories.UpLoadFile(file, fileSize)

	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"msg":  errormsg.GetErrorMsg(code),
		"url":  url,
	})
}
